#include<bits/stdc++.h>
#define ONLINE_JUDGE
#define ll long long
#define ull unsigned long long
using namespace std;

const ll N = 2e5 + 10, INF = 0x3f3f3f3f;

int n;
string s;
ll cnt[26][N];

void solve()
{
    cin >> s;
    n = s.length();
    s = " " + s;
    for (int i = 1;i <= n;i++) {
        for (int j = 0;j < 26;j++)
            cnt[j][i] = cnt[j][i - 1] + ((s[i] - 'A') == j);
    }

    ll ans = 0;
    for (int i = 2;i <= n;i++)
        for (int j = 0;j < 26;j++)
            ans += cnt[j][i - 1] * (cnt[j][n] - cnt[j][i]);

    cout << ans;
}

signed main()
{
    // ios::sync_with_stdio(0);
    // cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
    std::istringstream in(R"()");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll T = 1;
    //cin>>T;
    for (ll i = 1;i <= T;i++) {
        solve();
    }
}